package br.com.hendges.canastra;

import android.R.string;
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class CanastraActivity extends Activity {
	Button btCalcular, btLimpar;
	EditText etNos, etNos1, etNos2, etNos3, etNos4, etEles, etEles1, etEles2,
			etEles3, etEles4;
	Integer nos, eles;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		etNos = (EditText) findViewById(R.et.etNos);
		etNos1 = (EditText) findViewById(R.et.etNos1);
		etNos2 = (EditText) findViewById(R.et.etNos2);
		etNos3 = (EditText) findViewById(R.et.etNos3);
		etNos4 = (EditText) findViewById(R.et.etNos4);
		etEles = (EditText) findViewById(R.et.etEles);
		etEles1 = (EditText) findViewById(R.et.etEles1);
		etEles2 = (EditText) findViewById(R.et.etEles2);
		etEles3 = (EditText) findViewById(R.et.etEles3);
		etEles4 = (EditText) findViewById(R.et.etEles4);
		btLimpar = (Button) findViewById(R.bt.btLimpar);
		btCalcular = (Button) findViewById(R.bt.btCalcular);

		etNos1.setOnLongClickListener(new View.OnLongClickListener() {
			public boolean onLongClick(View v) {
				etNos1.setText("");
				return true;
			}
		});
		etNos2.setOnLongClickListener(new View.OnLongClickListener() {
			public boolean onLongClick(View v) {
				etNos2.setText("");
				return true;
			}
		});
		etNos3.setOnLongClickListener(new View.OnLongClickListener() {
			public boolean onLongClick(View v) {
				etNos3.setText("");
				return true;
			}
		});
		etNos4.setOnLongClickListener(new View.OnLongClickListener() {
			public boolean onLongClick(View v) {
				etNos4.setText("");
				return true;
			}
		});
		etEles1.setOnLongClickListener(new View.OnLongClickListener() {
			public boolean onLongClick(View v) {
				etEles1.setText("");
				return true;
			}
		});
		etEles2.setOnLongClickListener(new View.OnLongClickListener() {
			public boolean onLongClick(View v) {
				etEles2.setText("");
				return true;
			}
		});
		etEles3.setOnLongClickListener(new View.OnLongClickListener() {
			public boolean onLongClick(View v) {
				etEles3.setText("");
				return true;
			}
		});
		etEles4.setOnLongClickListener(new View.OnLongClickListener() {
			public boolean onLongClick(View v) {
				etEles4.setText("");
				return true;
			}
		});

		btCalcular.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				nos = (Integer.parseInt(etNos1.getText().toString()))
						+ (Integer.parseInt(etNos2.getText().toString()))
						+ (Integer.parseInt(etNos3.getText().toString()))
						+ (Integer.parseInt(etNos4.getText().toString()));
				etNos.setText(String.valueOf(nos));
				
				eles= (Integer.parseInt(etEles1.getText().toString()))
						+ (Integer.parseInt(etEles2.getText().toString()))
						+ (Integer.parseInt(etEles3.getText().toString()))
						+ (Integer.parseInt(etEles4.getText().toString()));
				etEles.setText(String.valueOf(eles));
			}
		});
		btLimpar.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				etNos.setText("");
				etNos1.setText("0");
				etNos2.setText("0");
				etNos3.setText("0");
				etNos4.setText("0");
				etEles.setText("");
				etEles1.setText("0");
				etEles2.setText("0");
				etEles3.setText("0");
				etEles4.setText("0");
			}
		});

	}
}